package com.anhry.www.safety.manage.zczb.struts.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.anhry.www.safety.manage.enterprise.bean.TbCorpInfo;
import com.anhry.www.safety.manage.zczb.bean.TbZczbYh;
import com.anhry.www.safety.manage.zczb.struts.base.ZczbBaseAction;
import com.anhry.www.safety.util.Loggers;
import com.anhry.www.safety.util.Page;
import com.anhry.www.safety.util.Util;

/**
 * @date:2012-10-23
 * @remark:重大隐患操作
 * @author:dongbin
 */

@Controller
@Scope("prototype")
@SuppressWarnings("unchecked")
public class BigYhAction extends ZczbBaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * 重大隐患列表
	 * @return
	 */
	public String list(){
		int rowCount = 0;
		int num = (this.num != null && !"".equals(this.num ))?Integer.parseInt(this.num ):1;
		int size = (this.size != null && !"".equals(this.size ))?Integer.parseInt(this.size ):10;
		try {
			TbCorpInfo corp = (TbCorpInfo)this.contextPvd.getSessionAttr(Util.SESSION_CORPUSER);
			String orderHql = " order by t.yhFxTime desc";//排序hql语句
			StringBuilder hql = new StringBuilder(" where 1=1 and t.corpId="+corp.getId()+" and t.yhType=2");
			if(null!=this.cBtime && this.cBtime.length()>0 && null!=this.cEtime && this.cEtime.length()>0){
				hql.append(" and to_char(t.yhFxTime,'yyyy-mm-dd') between '"+cBtime+"' and '"+cEtime+"'");
			}
			List objSize = this.utilService.getObjecList("TbZczbYh", hql.toString(), orderHql,0, 0);
			if(objSize != null && objSize.size() > 0){
				rowCount = Integer.parseInt(objSize.get(0).toString());
			}
			Page page = new Page(size,num,rowCount);
			this.setPage(page);
			this.setObjList(this.utilService.getObjecList("TbZczbYh", hql.toString(), orderHql,page.getStartRow(),page.getSize()));
			this.setResult("big_list");
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("zczb: BigYhAction:list() 异常："+e.getMessage());
		}
		return ERROR;
	}
	
	/**
	 * 跳转到操作页面
	 * @return
	 */
	public String yhZgShow(){
		try {
			if(null!=this.yhId && this.yhId.length()>0){
				TbZczbYh yh = (TbZczbYh)this.utilService.getObjectById(TbZczbYh.class, Long.parseLong(this.yhId));
				if(null!=yh){
					this.setYh(yh);
					this.setFjList1(this.zczbService.getYhFjList("4", this.yhId));
					this.setResult("big_zg_show");
					return SUCCESS;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.info("zczb BigYhAction corpYhAudit()异常："+e.getMessage());
		}
		return ERROR;
	}

}
